<?php 
	echo $this->render('header.phtml'); 
?>

<div class="bar">
<?php echo $this->menu ?>
</div>
<div class="search_field">
	<form method="post" action="<?php echo $this->baseUrl ?>/paciente">
		<p><input type="text" name="search" class="search" /> <input type="submit" value="Buscar" class="searchSubmit" /></p>
		<input type="hidden" name="buscar" value="true" />
	</form>
</div>
<h1><?php echo $this->escape($this->title); ?></h1>
<p><a href="<?php echo $this->baseUrl; ?>/paciente/adicionar">Adicionar Novo Paciente</a></p>
<div> 
<table id="myTable"> 
	<colgroup> 
		<col style="width:20%"></col> 
		<col style="width:20%"></col> 
		<col style="width:20%"></col> 
		<col></col> 
		<col></col> 
	</colgroup> 
	<thead> 
		<tr> 
			<td sortBy="id">ID</td> 
			<td sortBy="nome">Nome</td> 
			<td sortBy="n_sus">SUS</td> 
			<td sortBy="fone">Fone</td>
			<td sortBy="nada">&nbsp;</td>
			<td sortBy="nada">&nbsp;</td>
		</tr> 
	</thead> 
	<tbody> 
		<TR> 
				<TD></TD>				
				<TD></TD>				
				<TD></TD>				
				<TD></TD>
				<TD></td>
				<TD></td>		
		</TR>		
	</tbody> 
</table> 
</div> 
 
<div id="tableWidgetPagina"></div>
 
 
<script type="text/javascript"> 
 
var tableWidgetObj = new DHTMLSuite.tableWidget();
DHTMLSuite.commonObj.setCssCacheStatus(false)
 
tableWidgetObj.setTableId('myTable');
tableWidgetObj.setTableWidth('100%');
tableWidgetObj.setTableHeight(300);
tableWidgetObj.setServerSideSort(true);
tableWidgetObj.setColumnSort(Array('N','S','S','S','S'));	// The value doesn't matter here since we're using server side sort. However, we need to set a value for the sortable columns.
tableWidgetObj.setServersideSortFileName('<?php 
												if(!empty($_POST['buscar'])){
													echo $this->baseUrl."/paciente/listar?filtro=".$_POST['search'];
													//break;
												}else{
													echo $this->baseUrl."/paciente/listar";
												}?>');	// Specify server side file name
tableWidgetObj.setServersideSortNumberOfRows(10);	// Receive 10 rows from the server
tableWidgetObj.init();
tableWidgetObj.updateTableHeader(0,'ascending');
 
// Creating pagina object
 
var pagehandler = new DHTMLSuite.tableWidgetPageHandler();
pagehandler.setTargetId('tableWidgetPagina');	// Specify where to insert the paginating object.
pagehandler.setTableRef(tableWidgetObj);	// Specify where to insert the paginating object.
pagehandler.setMaximumNumberOfPageLinks(2);
pagehandler.setTotalNumberOfRows();
pagehandler.init();
</script> 


<?php echo $this->render('footer.phtml'); ?>